Skip to content

Harden document linter heuristics, report output, and test coverage#39

Merged
feddernico merged 5 commits into
mainfrom
feat/writing-tests
Jun 2, 2026
Merged

Harden document linter heuristics, report output, and test coverage#39
feddernico merged 5 commits into
mainfrom
feat/writing-tests

Conversation

@feddernico

Copy link
Copy Markdown
Owner

Summary

This PR hardens the Document Linter so its output is more trustworthy, more actionable, and better covered by tests.

What changed

  • Removed the fake async setTimeout from the analysis path.
  • Unified sentence tokenization behind one helper and documented its limits.
  • Expanded markdown parsing to handle:
    • ordered lists
    • Setext headings
    • indented code blocks
    • unterminated fenced code blocks
  • Deduplicated pseudo-section-label detection.
  • Replaced regex-based “needs attention” inference with explicit section metadata.
  • Added an aggregate overall score to both the panel and markdown export.
  • Reworked engagement/strength heuristics to use generic signals instead of topic-specific phrases.
  • Penalized thin / low-signal drafts more aggressively.
  • Added repeated-word detection for obvious low-quality text.
  • Extracted linter copy into a dedicated messages.ts module.
  • Added a Rerun on change toggle in the linter panel.
  • Added clickable section line links that jump back into the editor.
  • Preserved panel scroll during refresh and added best-effort focus restoration.
  • Made export explicitly announce when it must re-analyze before generating a report.

Tests

Added/expanded QUnit coverage for:

  • markdown parsing edge cases
  • section building in isolation
  • markdown export snapshot output
  • empty / heading-only / single-word inputs
  • list items not counting as prose sentences
  • controller behavior
  • low-signal / repetitive draft scoring

Validation

  • npm run build:test
  • npx qunit tests/qunit/document-linter.test.js
  • npm run test:qunit
  • npm run build

Notes

  • The build still reports two pre-existing ESLint warnings in tests/qunit/auth.test.js.
  • The panel still rebuilds its markup on refresh, but scroll is now preserved and focus restoration is attempted, so the refresh is less disruptive than before.

Federico Viscioletti and others added 2 commits May 31, 2026 09:02
- Add Document Linter that analyzes the currently open markdown document
- Parse front matter, headings, prose, code chunks, callouts, lists, and links
- Ignore or downweight code chunks to focus on human-facing text
- Return actionable suggestions grouped into clarity, flow, scannability, and engagement
- Implement rule-based tests plus a scoring layer for analysis
- Generate suggestions tied to exact lines or sections like a code review
- Build as a small web app with three stages: parse, analyze, generate suggestions
- Include a practical rules engine with checks like readability.max_sentence_length, structure.heading_depth_jump, etc.
- Create a simple single-page app with score panel and inline suggestions in the editor
- Implement markdown-aware parsing to isolate prose from code
- Use rule-based checks first, with optional LLM suggestions second
- Output section-by-section report plus optional 'improved draft' mode
@feddernico feddernico added the enhancement New feature or request label Jun 2, 2026
@feddernico feddernico merged commit eac9ba9 into main Jun 2, 2026
5 checks passed
@feddernico feddernico deleted the feat/writing-tests branch June 2, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant